import Vue from 'vue'
import Router from 'vue-router'
import _import from '@/router/_import'
import Layout from '@/views/layout'
import {CmsRouterMap} from './CmsRouter'
import {SystemRouterMap} from './SystemRouter'

Vue.use(Router)

/**
 * hidden: true                     if `hidden:true` will not show in the sidebar(default is false)
 * redirect: noredirect             if `redirect:noredirect` will no redirct in the breadcrumb
 * noDropDown: true                 只显示一级菜单，不显示子菜单
 * name:'router-name'               the name is used by <keep-alive> (must set!!!)
 * 404路由必须放到路由最后
 */

export const page401 = {
    path: '/401',
    name: '权限不足',
    component: _import('error/Page401'),
    hidden: true
};

export const page404 = {
    path: '/*',
    name: '页面不存在',
    component: _import('error/Page404'),
    hidden: true
};

export const page500 = {
    path: '/500',
    name: '服务端错误',
    component: _import('error/Page500'),
    hidden: true
};

export const loginRouter = {
    path: '/login',
    name: '登录',
    component: _import('login/index'),
    hidden: true
};

export const profileRouter = {
    path: '/profile',
    component: Layout,
    hidden: true,
    name: '个人中心',
    children: [
        {path: 'profile', name: '我的信息', component: _import('profile/index')},
        {path: 'message', name: '消息中心', component: _import('profile/MyMessage')}
    ]
}

/**
 * 公共路由
 */
export const commonRouters = [
    loginRouter,
    profileRouter,
    page500,
    page401
]

/**
 * 业务路由内容管理系统
 */
export const CmsRouter = [...CmsRouterMap, page404]

/**
 * 业务路由系统管理
 */
export const SystemRouter = [...SystemRouterMap, page404]


export default new Router({
    routes: commonRouters
})